#include<bits/stdc++.h>
#define ll long long
#define pn putchar('\n')
#define fls() fflush(stdout)
#define mset(a,x) memset(a,x,sizeof a)
#define mcpy(a,b) msmcpy(a,b,sizeof a)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define maxn 1000005
using namespace std;
int n,m,L,V;
int pre[maxn];
void solve()
{
	scanf("%d%d%d%d",&n,&m,&L,&V);
	vector<pii>a;
	int la=0;
	while(n--)
	{
		int d,v,va;
		scanf("%d%d%d",&d,&v,&va);
		if(!va&&v>V)
			a.push_back({d,L});
		if(va>0)
		{
			if(v>V)
				a.push_back({d,L});
			else
			{
				int l=d+(V*V-v*v)/(2*va)+1;
				if(l<=L)
					a.push_back({l,L});
			}
		}
		if(va<0&&v>V)
		{
			int r=(V*V-v*v)/(2*va);
			if(v*v+2*va*r==V*V)
				r--;
			r+=d;
			if(r>L)
				r=L;
			a.push_back({d,r});
		}
	}
	sort(all(a),[](pii x,pii y){return x.second==y.second?x.first>y.first:x.second<y.second;});
	mset(pre,-1);
	for(int i=1;i<=m;i++)
	{
		int x;
		scanf("%d",&x);
		pre[x]=x;
	}
	for(int i=1;i<=L;i++)
	{
		if(!~pre[i])
			pre[i]=pre[i-1];
	}
	int mxl=-1,now=-1,cnt=0,use=m;
	for(auto it=a.begin();it!=a.end();it++)
	{
		int l=it->first,r=it->second;
		if(pre[r]<l)
			continue;
		cnt++;
		if(l>mxl)
		{
			mxl=l;
			if(l>now)
			{
				use--;
				now=pre[r];
			}
		}
	}
	printf("%d %d\n",cnt,use);

}
int main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int T;
	scanf("%d",&T);
	while(T--)
		solve();
	return 0;
}